<script>
export default {
  data() {
    return {
      input: {
        login: '',
        password: ''
      },
      display_err_login: 'none',
      display_err_password: 'none',
      display_err_auth: 'none',
    }
  },
  methods: {
    redirect_to_home() {
      this.$router.push('/home')
    },
    login() {
      if (this.input.login == '') {
        this.display_err_login = 'inline'
      } else { this.display_err_login = 'none' }
      if (this.input.password == '') {
        this.display_err_password = 'inline'
      } else { this.display_err_password = 'none' }
      if (this.input.login == '' || this.input.password == '') { return }
      if (this.input.login == 'test' && this.input.password == 'test') {
        this.$router.push('/home')
      } else {
        this.display_err_auth = 'inline'
      }
    }
  }
}
</script>

<template>
  <main>
    <div class="login_div">
      <div class="title_div">
        <img src="/public/img/back.svg" @click="redirect_to_home()" />
        <h2>ВХОД</h2>
        <label class="err_msg auth_label">Неверные логин/пароль</label>
      </div>
      <form @submit.prevent="login">
        <div class="inputs_div">
          <input v-model="input.login" placeholder="login" name="login" />
          <label class="err_msg login_label">Поле не может быть пустым</label>
          <input v-model="input.password" placeholder="password" name="password" />
          <label class="err_msg password_label">Поле не может быть пустым</label>
        </div>
        <div class="login_btn_div">
          <input class="button" type="submit" value="Войти" v-on:click="login()" />
        </div>
      </form>
    </div>
  </main>
</template>

<style scoped>
main {
  width: 100%;
}

.err_msg {
  margin-top: -2%;
  width: 467px;
  color: #fe0808;
  font-family: Montserrat;
  font-size: 15px;
  font-style: normal;
  font-weight: 600;
  line-height: normal;
}

.login_label {
  display: v-bind('display_err_login');
}

.password_label {
  display: v-bind('display_err_password');
}

.auth_label {
  margin: 0 auto;
  margin-left: 10%;
  display: v-bind('display_err_auth');
}

h2 {
  color: #241f5c;
  font-family: Montserrat;
  font-size: 36px;
  font-style: normal;
  font-weight: 600;
  line-height: normal;
  margin-left: 10px;
}

.inputs_div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

input {
  border: none;
  border-radius: 20px;
  background: rgba(103, 101, 101, 0.54);
  margin: 5%;
  width: 467px;
  height: 73px;
  flex-shrink: 0;
  color: #fff;
  font-family: Montserrat;
  font-size: 30px;
  padding: 2%;
  font-style: normal;
  font-weight: 600;
  line-height: normal;
}

.login_btn_div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.button {
  border: none;
  color: #fff;
  font-family: Inter;
  font-size: 24px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  width: 139px;
  height: 45px;
  flex-shrink: 0;
  border-radius: 20px;
  background: #241f5c;
  transition: 0.3s;
  padding: 0%;
}

.button:hover {
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.4);
}

.title_div {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin: 10px;
}

.login_div {
  margin: 0 auto;
  margin-top: 5%;
  width: 675px;
  height: 520px;
  border-radius: 20px;
  border: 1px solid #e4e4ed;
  background: #fff;
  padding: 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
</style>
